package com.blrs.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.blrs.common.core.page.PageDomain;
import com.blrs.common.core.page.TableSupport;
import com.blrs.common.utils.page.PaginationUtil;
import com.blrs.domain.ProjectFunding;
import com.blrs.domain.ProjectSchedule;
import com.blrs.service.project.funding.IProjectFundingService;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.blrs.common.annotation.Log;
import com.blrs.common.core.controller.BaseController;
import com.blrs.common.core.domain.AjaxResult;
import com.blrs.common.enums.BusinessType;
import com.blrs.common.utils.poi.ExcelUtil;
import com.blrs.common.core.page.TableDataInfo;

/**
 * 项目资金管理Controller
 * 
 * @author yuxiang.chen
 * @date 2023-08-10
 */
@RestController
@RequestMapping("/project/funding")
public class ProjectFundingController extends BaseController
{
    @Autowired
    private IProjectFundingService projectFundingService;

    /**
     * 查询项目资金管理列表
     */
    //@PreAuthorize("@ss.hasPermi('project:funding:list')")
    @GetMapping("/list")
    public TableDataInfo list(ProjectFunding projectFunding)
    {
        startPage();
        List<ProjectFunding> list = projectFundingService.selectProjectFundingList(projectFunding);
        return getDataTable(list);
    }

    /**
     * 导出项目资金管理列表
     */
    //@PreAuthorize("@ss.hasPermi('project:funding:export')")
    @Log(title = "项目资金", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ProjectFunding projectFunding)
    {
        List<ProjectFunding> list = projectFundingService.selectProjectFundingList(projectFunding);
        ExcelUtil<ProjectFunding> util = new ExcelUtil<ProjectFunding>(ProjectFunding.class);
        util.exportExcel(response, list, "项目资金管理数据");
    }

    /**
     * 获取项目资金管理详细信息
     */
    //@PreAuthorize("@ss.hasPermi('project:funding:query')")
    @GetMapping(value = "/{fundId}")
    public AjaxResult getInfo(@PathVariable("fundId") String fundId)
    {
        return success(projectFundingService.selectProjectFundingByFundId(fundId));
    }

    /**
     * 新增项目资金管理
     */
    //@PreAuthorize("@ss.hasPermi('project:funding:add')")
    @Log(title = "项目资金", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ProjectFunding projectFunding)
    {
        return toAjax(projectFundingService.insertProjectFunding(projectFunding));
    }

    /**
     * 修改项目资金管理
     */
    //@PreAuthorize("@ss.hasPermi('project:funding:edit')")
    @Log(title = "项目资金", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ProjectFunding projectFunding)
    {
        return toAjax(projectFundingService.updateProjectFunding(projectFunding));
    }

    /**
     * 删除项目资金管理
     */
    //@PreAuthorize("@ss.hasPermi('project:funding:remove')")
    @Log(title = "项目资金", businessType = BusinessType.DELETE)
	@DeleteMapping("/{fundIds}")
    public AjaxResult remove(@PathVariable String[] fundIds)
    {
        return toAjax(projectFundingService.deleteProjectFundingByFundIds(fundIds));
    }
}
